home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / javax / swing / JLabel$AccessibleJLabel.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  6.5 KB  |  370 lines

  1. package javax.swing;
  2.  
  3. import java.awt.Component;
  4. import java.awt.Insets;
  5. import java.awt.Point;
  6. import java.awt.Rectangle;
  7. import java.awt.Shape;
  8. import java.awt.geom.Rectangle2D;
  9. import java.text.BreakIterator;
  10. import javax.accessibility.Accessible;
  11. import javax.accessibility.AccessibleContext;
  12. import javax.accessibility.AccessibleExtendedComponent;
  13. import javax.accessibility.AccessibleIcon;
  14. import javax.accessibility.AccessibleKeyBinding;
  15. import javax.accessibility.AccessibleRelation;
  16. import javax.accessibility.AccessibleRelationSet;
  17. import javax.accessibility.AccessibleRole;
  18. import javax.accessibility.AccessibleText;
  19. import javax.swing.text.AttributeSet;
  20. import javax.swing.text.BadLocationException;
  21. import javax.swing.text.Document;
  22. import javax.swing.text.Element;
  23. import javax.swing.text.Position;
  24. import javax.swing.text.StyledDocument;
  25. import javax.swing.text.View;
  26. import javax.swing.text.Position.Bias;
  27.  
  28. public class JLabel$AccessibleJLabel extends JComponent.AccessibleJComponent implements AccessibleText, AccessibleExtendedComponent {
  29.    // $FF: synthetic field
  30.    final JLabel this$0;
  31.  
  32.    protected JLabel$AccessibleJLabel(JLabel var1) {
  33.       super(var1);
  34.       this.this$0 = var1;
  35.    }
  36.  
  37.    public String getAccessibleName() {
  38.       String var1 = this.accessibleName;
  39.       if (var1 == null) {
  40.          var1 = (String)this.this$0.getClientProperty("AccessibleName");
  41.       }
  42.  
  43.       if (var1 == null) {
  44.          var1 = this.this$0.getText();
  45.       }
  46.  
  47.       if (var1 == null) {
  48.          var1 = super.getAccessibleName();
  49.       }
  50.  
  51.       return var1;
  52.    }
  53.  
  54.    public AccessibleRole getAccessibleRole() {
  55.       return AccessibleRole.LABEL;
  56.    }
  57.  
  58.    public AccessibleIcon[] getAccessibleIcon() {
  59.       Icon var1 = this.this$0.getIcon();
  60.       if (var1 instanceof Accessible) {
  61.          AccessibleContext var2 = ((Accessible)var1).getAccessibleContext();
  62.          if (var2 != null && var2 instanceof AccessibleIcon) {
  63.             return new AccessibleIcon[]{(AccessibleIcon)var2};
  64.          }
  65.       }
  66.  
  67.       return null;
  68.    }
  69.  
  70.    public AccessibleRelationSet getAccessibleRelationSet() {
  71.       AccessibleRelationSet var1 = super.getAccessibleRelationSet();
  72.       if (!var1.contains(AccessibleRelation.LABEL_FOR)) {
  73.          Component var2 = this.this$0.getLabelFor();
  74.          if (var2 != null) {
  75.             AccessibleRelation var3 = new AccessibleRelation(AccessibleRelation.LABEL_FOR);
  76.             var3.setTarget(var2);
  77.             var1.add(var3);
  78.          }
  79.       }
  80.  
  81.       return var1;
  82.    }
  83.  
  84.    public AccessibleText getAccessibleText() {
  85.       View var1 = (View)this.this$0.getClientProperty("html");
  86.       return var1 != null ? this : null;
  87.    }
  88.  
  89.    public int getIndexAtPoint(Point var1) {
  90.       View var2 = (View)this.this$0.getClientProperty("html");
  91.       if (var2 != null) {
  92.          Rectangle var3 = this.getTextRectangle();
  93.          if (var3 == null) {
  94.             return -1;
  95.          } else {
  96.             Rectangle2D.Float var4 = new Rectangle2D.Float((float)var3.x, (float)var3.y, (float)var3.width, (float)var3.height);
  97.             Position.Bias[] var5 = new Position.Bias[1];
  98.             return var2.viewToModel((float)var1.x, (float)var1.y, var4, var5);
  99.          }
  100.       } else {
  101.          return -1;
  102.       }
  103.    }
  104.  
  105.    public Rectangle getCharacterBounds(int var1) {
  106.       View var2 = (View)this.this$0.getClientProperty("html");
  107.       if (var2 != null) {
  108.          Rectangle var3 = this.getTextRectangle();
  109.          if (var3 == null) {
  110.             return null;
  111.          } else {
  112.             Rectangle2D.Float var4 = new Rectangle2D.Float((float)var3.x, (float)var3.y, (float)var3.width, (float)var3.height);
  113.  
  114.             try {
  115.                Shape var5 = var2.modelToView(var1, var4, Bias.Forward);
  116.                return var5.getBounds();
  117.             } catch (BadLocationException var6) {
  118.                return null;
  119.             }
  120.          }
  121.       } else {
  122.          return null;
  123.       }
  124.    }
  125.  
  126.    public int getCharCount() {
  127.       View var1 = (View)this.this$0.getClientProperty("html");
  128.       if (var1 != null) {
  129.          Document var2 = var1.getDocument();
  130.          if (var2 instanceof StyledDocument) {
  131.             StyledDocument var3 = (StyledDocument)var2;
  132.             return var3.getLength();
  133.          }
  134.       }
  135.  
  136.       return this.this$0.accessibleContext.getAccessibleName().length();
  137.    }
  138.  
  139.    public int getCaretPosition() {
  140.       return -1;
  141.    }
  142.  
  143.    public String getAtIndex(int var1, int var2) {
  144.       if (var2 >= 0 && var2 < this.getCharCount()) {
  145.          switch (var1) {
  146.             case 1:
  147.                try {
  148.                   return this.getText(var2, 1);
  149.                } catch (BadLocationException var8) {
  150.                   return null;
  151.                }
  152.             case 2:
  153.                try {
  154.                   String var9 = this.getText(0, this.getCharCount());
  155.                   BreakIterator var10 = BreakIterator.getWordInstance(this.getLocale());
  156.                   var10.setText(var9);
  157.                   int var11 = var10.following(var2);
  158.                   return var9.substring(var10.previous(), var11);
  159.                } catch (BadLocationException var7) {
  160.                   return null;
  161.                }
  162.             case 3:
  163.                try {
  164.                   String var3 = this.getText(0, this.getCharCount());
  165.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  166.                   var4.setText(var3);
  167.                   int var5 = var4.following(var2);
  168.                   return var3.substring(var4.previous(), var5);
  169.                } catch (BadLocationException var6) {
  170.                   return null;
  171.                }
  172.             default:
  173.                return null;
  174.          }
  175.       } else {
  176.          return null;
  177.       }
  178.    }
  179.  
  180.    public String getAfterIndex(int var1, int var2) {
  181.       if (var2 >= 0 && var2 < this.getCharCount()) {
  182.          switch (var1) {
  183.             case 1:
  184.                if (var2 + 1 >= this.getCharCount()) {
  185.                   return null;
  186.                } else {
  187.                   try {
  188.                      return this.getText(var2 + 1, 1);
  189.                   } catch (BadLocationException var9) {
  190.                      return null;
  191.                   }
  192.                }
  193.             case 2:
  194.                try {
  195.                   String var10 = this.getText(0, this.getCharCount());
  196.                   BreakIterator var11 = BreakIterator.getWordInstance(this.getLocale());
  197.                   var11.setText(var10);
  198.                   int var12 = var11.following(var2);
  199.                   if (var12 != -1 && var12 < var10.length()) {
  200.                      int var13 = var11.following(var12);
  201.                      if (var13 != -1 && var13 < var10.length()) {
  202.                         return var10.substring(var12, var13);
  203.                      }
  204.  
  205.                      return null;
  206.                   }
  207.  
  208.                   return null;
  209.                } catch (BadLocationException var8) {
  210.                   return null;
  211.                }
  212.             case 3:
  213.                try {
  214.                   String var3 = this.getText(0, this.getCharCount());
  215.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  216.                   var4.setText(var3);
  217.                   int var5 = var4.following(var2);
  218.                   if (var5 != -1 && var5 <= var3.length()) {
  219.                      int var6 = var4.following(var5);
  220.                      if (var6 != -1 && var6 <= var3.length()) {
  221.                         return var3.substring(var5, var6);
  222.                      }
  223.  
  224.                      return null;
  225.                   }
  226.  
  227.                   return null;
  228.                } catch (BadLocationException var7) {
  229.                   return null;
  230.                }
  231.             default:
  232.                return null;
  233.          }
  234.       } else {
  235.          return null;
  236.       }
  237.    }
  238.  
  239.    public String getBeforeIndex(int var1, int var2) {
  240.       if (var2 >= 0 && var2 <= this.getCharCount() - 1) {
  241.          switch (var1) {
  242.             case 1:
  243.                if (var2 == 0) {
  244.                   return null;
  245.                } else {
  246.                   try {
  247.                      return this.getText(var2 - 1, 1);
  248.                   } catch (BadLocationException var9) {
  249.                      return null;
  250.                   }
  251.                }
  252.             case 2:
  253.                try {
  254.                   String var10 = this.getText(0, this.getCharCount());
  255.                   BreakIterator var11 = BreakIterator.getWordInstance(this.getLocale());
  256.                   var11.setText(var10);
  257.                   var11.following(var2);
  258.                   int var12 = var11.previous();
  259.                   int var13 = var11.previous();
  260.                   if (var13 == -1) {
  261.                      return null;
  262.                   }
  263.  
  264.                   return var10.substring(var13, var12);
  265.                } catch (BadLocationException var8) {
  266.                   return null;
  267.                }
  268.             case 3:
  269.                try {
  270.                   String var3 = this.getText(0, this.getCharCount());
  271.                   BreakIterator var4 = BreakIterator.getSentenceInstance(this.getLocale());
  272.                   var4.setText(var3);
  273.                   var4.following(var2);
  274.                   int var5 = var4.previous();
  275.                   int var6 = var4.previous();
  276.                   if (var6 == -1) {
  277.                      return null;
  278.                   }
  279.  
  280.                   return var3.substring(var6, var5);
  281.                } catch (BadLocationException var7) {
  282.                   return null;
  283.                }
  284.             default:
  285.                return null;
  286.          }
  287.       } else {
  288.          return null;
  289.       }
  290.    }
  291.  
  292.    public AttributeSet getCharacterAttribute(int var1) {
  293.       View var2 = (View)this.this$0.getClientProperty("html");
  294.       if (var2 != null) {
  295.          Document var3 = var2.getDocument();
  296.          if (var3 instanceof StyledDocument) {
  297.             StyledDocument var4 = (StyledDocument)var3;
  298.             Element var5 = var4.getCharacterElement(var1);
  299.             if (var5 != null) {
  300.                return var5.getAttributes();
  301.             }
  302.          }
  303.       }
  304.  
  305.       return null;
  306.    }
  307.  
  308.    public int getSelectionStart() {
  309.       return -1;
  310.    }
  311.  
  312.    public int getSelectionEnd() {
  313.       return -1;
  314.    }
  315.  
  316.    public String getSelectedText() {
  317.       return null;
  318.    }
  319.  
  320.    private String getText(int var1, int var2) throws BadLocationException {
  321.       View var3 = (View)this.this$0.getClientProperty("html");
  322.       if (var3 != null) {
  323.          Document var4 = var3.getDocument();
  324.          if (var4 instanceof StyledDocument) {
  325.             StyledDocument var5 = (StyledDocument)var4;
  326.             return var5.getText(var1, var2);
  327.          }
  328.       }
  329.  
  330.       return null;
  331.    }
  332.  
  333.    private Rectangle getTextRectangle() {
  334.       String var1 = this.this$0.getText();
  335.       Icon var2 = this.this$0.isEnabled() ? this.this$0.getIcon() : this.this$0.getDisabledIcon();
  336.       if (var2 == null && var1 == null) {
  337.          return null;
  338.       } else {
  339.          Rectangle var3 = new Rectangle();
  340.          Rectangle var4 = new Rectangle();
  341.          Rectangle var5 = new Rectangle();
  342.          Insets var6 = new Insets(0, 0, 0, 0);
  343.          var6 = this.this$0.getInsets(var6);
  344.          var5.x = var6.left;
  345.          var5.y = var6.top;
  346.          var5.width = this.this$0.getWidth() - (var6.left + var6.right);
  347.          var5.height = this.this$0.getHeight() - (var6.top + var6.bottom);
  348.          SwingUtilities.layoutCompoundLabel(this.this$0, this.getFontMetrics(this.getFont()), var1, var2, this.this$0.getVerticalAlignment(), this.this$0.getHorizontalAlignment(), this.this$0.getVerticalTextPosition(), this.this$0.getHorizontalTextPosition(), var5, var3, var4, this.this$0.getIconTextGap());
  349.          return var4;
  350.       }
  351.    }
  352.  
  353.    AccessibleExtendedComponent getAccessibleExtendedComponent() {
  354.       return this;
  355.    }
  356.  
  357.    public String getToolTipText() {
  358.       return this.this$0.getToolTipText();
  359.    }
  360.  
  361.    public String getTitledBorderText() {
  362.       return super.getTitledBorderText();
  363.    }
  364.  
  365.    public AccessibleKeyBinding getAccessibleKeyBinding() {
  366.       int var1 = this.this$0.getDisplayedMnemonic();
  367.       return var1 == 0 ? null : new JLabel.AccessibleJLabel.LabelKeyBinding(this, var1);
  368.    }
  369. }
  370.